/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

/**
 * 业务员管理菜单
 *  */
// eslint-disable-next-line import/no-extraneous-dependencies
import { Request, Response } from 'express';
import { responseSuccess } from '../utils';
import Mock from 'mockjs';

export default {
  // 获取数据库列表
  'POST /showProcessList/getDbName': (req: Request, res: Response) => {
    return res.json({
      code: 0,
      data: {
        Address: 'address',
        App: 'market',
        Base: 'users',
        Bussiness_log: 'bussiness_log',
        cloudprint: 'cloud_print',
        Core: 'kd_shop',
        Finance: 'finance',
        history71: 'ivr_his',
        history_orders: 'minpost_his',
        history_sms: 'base_msg',
        Identity: 'realname',
        inn_info: 'inn_base',
        judanke: 'city_delivery',
        Log: 'dts',
        Message: 'feedback',
        new_base: 'base_service',
        Newcore: 'inn',
        NewInn: 'inn',
        Open: 'open_platform',
        orders: 'orders',
        PDA: 'pda',
        WS: 'vhome',
      },
      msg: 'success',
    });
  },
  // 获取列表
  'POST /showProcessList/showProcessList': (req: Request, res: Response) => {
    return res.json({
      code: 0,
      data: Mock.mock({
        'list|10': [
          {
            Id: '142006663',
            User: 'db_test_2020',
            Host: '10.20.81.129:56605',
            db: 'dts',
            Command: 'Sleep',
            Time: '20',
            State: '',
            Info: null,
            sql: '',
          },
        ],
      }).list,
      msg: 'success',
    });
  },
  // 删除指定进程
  'POST /showProcessList/killProcess': (req: Request, res: Response) => responseSuccess(req, res),
  // 执行sql
  'POST /showProcessList/querySql': (req: Request, res: Response) => {
    const { sql = '' } = req.body;
    return res.json(
      Mock.mock({
        'code|1': [0, 1],
        data: {
          sql,
          'result|1': ['0', '1'],
          message: '说明',
          effect_rows: '@id',
          real_effect_rows: '@id',
          info: [
            {
              sql,
            },
          ],
          User: '@cname',
        },
        msg: 'success',
      }),
    );
  },
};
